//
//  NSObject+AssociatedObject.m
//  runtime
//
//  Created by eport on 2020/12/14.
//

/*
 文章参考 https://www.jianshu.com/p/916aef6f7ab1
 */

#import "NSObject+AssociatedObject.h"
#import <objc/runtime.h>

@implementation NSObject (AssociatedObject)

- (void)setAssociatedObject:(id)associatedObject
{
    //注意最后一个参数的类型
    objc_setAssociatedObject(self, @selector(associatedObject), associatedObject, OBJC_ASSOCIATION_COPY);
}

- (id)associatedObject
{
    return objc_getAssociatedObject(self, _cmd);
}



@end
